// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
import * as vscode from 'vscode';
import { WebviewViewProvider } from './webviewViewProvider';
import { WebviewPanelManager } from './webviewPanel';

// This method is called when your extension is activated
// Your extension is activated the very first time the command is executed
export function activate(context: vscode.ExtensionContext) {
	console.log('Cursor Restore 扩展已激活');

	// 创建 Webview 视图提供者（侧边栏面板）
	const webviewViewProvider = new WebviewViewProvider(context.extensionUri, context);

	// 注册 Webview 视图提供者
	context.subscriptions.push(
		vscode.window.registerWebviewViewProvider(
			WebviewViewProvider.viewType,
			webviewViewProvider
		)
	);

	// 创建 Webview 面板管理器（独立窗口）
	const webviewPanelManager = new WebviewPanelManager(context);

	// 注册打开独立 Webview 面板命令
	context.subscriptions.push(
		vscode.commands.registerCommand('cursor-restore.openPanel', () => {
			webviewPanelManager.createOrShow();
		})
	);

	// 注册刷新命令
	context.subscriptions.push(
		vscode.commands.registerCommand('cursor-restore.refresh', () => {
			webviewViewProvider.refresh();
			vscode.window.showInformationMessage('已刷新面板');
		})
	);
}

// This method is called when your extension is deactivated
export function deactivate() { }
